﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Kawanon.Usability;

namespace Kawanon.QtHoney
{
	public partial class GestureEditForm : Form
	{
		public GestureExpression Expression { get; set; }

		public GestureEditForm()
		{
			InitializeComponent();
		}

		private void UpdateUrdl(GestureExpression expr)
		{
			Expression = expr;

			textBoxUrdl.Text = expr.FormatTrails();
			textBoxUrdl.SelectionStart = textBoxUrdl.TextLength;
			gesturePanel1.Focus();
		}

		private void gesturePanel1_GestureDetected(object sender, GestureEventArgs e)
		{
			UpdateUrdl(e.Expression);
		}

		private void gesturePanel1_MaybeGestureStarted(object sender, MouseEventArgs e)
		{
			//textBoxUrdl.Clear();
		}

		private void gesturePanel1_TrailDetected(object sender, GestureEventArgs e)
		{
			UpdateUrdl(e.Expression);
		}

		private void GestureEditForm_Load(object sender, EventArgs e)
		{
			if (Expression != null)
			{
				UpdateUrdl(Expression);

				textBoxName.Text = Expression.Name;
			}
		}
	}
}
